#ifndef     __ALOG_H
#define     __ALOG_H

#include <stdint.h>

namespace utils::alg {

template <typename T>
inline T sum_xor(const T* buf, uint32_t count) {
    T val = 0;
    for (uint32_t i = 0; i < count; i ++) {
        val ^= buf[i];
    }
    return val;
}

inline uint8_t sum_add(const uint8_t *buf, uint32_t count) {
    uint8_t s = 0;
    for (uint32_t i = 0; i < count; i ++) {
        s += buf[i];
    }
    return s;
}

template <typename A, typename B>
inline auto abs(A a, B b) {
    if (a > b) {
        return a - b;
    }
    return b - a;
}


}


#endif
